 /**
 * @每次操作的字符根据上一次的数据进行计算
 *
 * @author	 wangshikun <wangshikun2010@gmail.com>
 * @copyright	(c) 2012 wangshikun <wangshikun2010@gmail.com>
 * @license	http://www.opensource.org/licenses/mit-license.php The MIT License
 * @package	default
 * @subpackage	default
 */

#include <stdio.h>
#include <cs50.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {
	float a;
	float s;
	char c;
	bool end = false;

	printf("Begin Calculations：\n");

	do {
		scanf("%f %c", &a, &c);
	
		switch (c) {
			case 'S':
				s = a; break;
			case '+':
				s += a; break;
			case '-':
				s -= a; break;
			case '*':
				s *= a; break;
			case '/':
				if (a == 0) {
					printf("除数不能为0\n");
				} else {
					s /= a;
				}
				
				break;
				
			case 'E':
				end = true;
				break;
			default:
				printf("未知的操作符\n");
				break;
		}

		printf("=%f\n", s);

		if (end) {
			printf("end calculations\n");
			break;
		}

	} while (true);
}
